#include "NGram.h"

namespace nflt
{

	template <typename T, unsigned int N>
	NGram<T,N>::NGram(void)
	{
	}

	template <typename T, unsigned int N>
	NGram<T,N>::~NGram(void)
	{
	}

	template <typename T, unsigned int N>
	bool NGram<T,N>::learn(const T* stream, size_t length, unsigned int index)
	{
		if (length < N)
			return false;

		size_t offset = 0;

		while (offset+N <= length) {
			learn_token(&stream[offset], index);
			++offset;
		}

		return true;
	}

	template <typename T, unsigned int N>
	bool NGram<T,N>::learn_token(const T* token, unsigned int index)
	{
		index_list& indexList = graph_.get_bottom_indexlist(token);
		indexList.push_back(index);

		return true;
	}

}